<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Dashboard extends CI_Controller {

    public function index() {
        $this->load->library('graph');
        $bar = new bar_outline(60, '#26610C', '#000000');
        
        
        $this->load->model('Laporan_model');
        $query2 = $this->Laporan_model->get_laporan_sorted_5();
        
        
        $this->load->model('Sekolah_model');
        $query = $this->Sekolah_model->get_sekolah_unsorted();

        $x_label = array();
        
        foreach ($query->result_array() as $row) {
            $bar->data[] = $row['jumlah_laporan'];
            $x_label[] = $row['nama_sekolah'];
        }
        
        $query1 = $this->Sekolah_model->get_sekolah_sorted()->row_array();
        $y_max = $query1['jumlah_laporan'];


        
        //graph layout
        
//        $bar->key('', 20);
        $this->graph->title(' ', '{font-size: 12px; padding: 10px}');
        $this->graph->data_sets[] = $bar;
        $this->graph->set_x_labels($x_label);
        $this->graph->set_x_label_style(8, '#000000', 2, 1);
        $this->graph->set_x_axis_steps(0);
        $this->graph->set_y_max($y_max);
        $this->graph->y_label_steps(1);
        $this->graph->set_y_legend('Jumlah Laporan', 8, '#000000');
        
        
        $data2['main_view'] = 'dashboard';
        $data2['query'] = $query2;
        $this->load->view('template', $data2);
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */